package com.sc.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sc.mapper.MenuMapper;
import com.sc.pojo.Menu;
import com.sc.service.MenuService;
import org.apache.xmlbeans.impl.jam.mutable.MPackage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional
public class MenuServiceImpl implements MenuService {
    @Autowired
    MenuMapper mapper;
    @Override
    public PageInfo<Menu> show(Integer pageNum, Integer pageSize,String keyword) {
        PageHelper.startPage(pageNum, pageSize);
        return new PageInfo<>(mapper.queryAll(keyword));
    }

    @Override
    public List<Menu> queryAll() {
        return mapper.queryAll(null);
    }

    @Override
    public int add(Menu m) {
        return mapper.insertSelective(m);
    }

    @Override
    public int del(Integer id) {
        return mapper.deleteByPrimaryKey(id);
    }

    @Override
    public int upd(Menu m) {
        return mapper.updateByPrimaryKeySelective(m);
    }

    @Override
    public int delAll(Integer[] ids) {
        return mapper.delAll(ids);
    }

    @Override
    public int openAll(Integer[] id) {
        return mapper.openAll(id);
    }

    @Override
    public int closeAll(Integer[] id) {
        return mapper.closeAll(id);
    }
}
